#!/bin/sh
# srcromprog0
set -x
# SCA2 1434 channels 3 and 4
# x:0x0000003c is location of the LSB of the 56002 host port.
# hwblkio writes bytes in sequence to y addresses:
#	223c - 2*4  = 2234
#	223c - 1*4  = 2238
#	223c - 0*4  = 223c
############################################ source off
#srcoff
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xB3B3B3B3

# The host port must be in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1

############################################ erase flash
# MONCMD_ERASESYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001D0003
# sent erase command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA5A5A5A5
# let src erase
sleep 20

############################################ MON_BOOT:
BINFILE=monboot.bin
SEGADDR=0x0000c000
SEGSIZE=0x00000180

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 5
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ MON_VECTS
BINFILE=monvects.bin
SEGADDR=0x0000c480
SEGSIZE=0x00000068

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 5
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ SEGTBL:
BINFILE=segtbl.bin
SEGADDR=0x0000c600
SEGSIZE=0x00000080

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 5
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ MAIN0:
BINFILE=main0.bin
SEGADDR=0x0000c780
SEGSIZE=0x00003d80

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 15
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ MAINY0:
BINFILE=mainy0.bin
SEGADDR=0x00028000
SEGSIZE=0x00000400

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 10
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ SINE2:
BINFILE=sine2.bin
SEGADDR=0x00028c00
SEGSIZE=0x00000600

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ RANDBB2
BINFILE=randbb2.bin
SEGADDR=0x00029e00
SEGSIZE=0x00000A00

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 10
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 


############################################ RANDZ2
BINFILE=randz2.bin
SEGADDR=0x0002bc00
SEGSIZE=0x00000a00

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 10
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ ARBBB2
BINFILE=arbbb2.bin
SEGADDR=0x0002da00
SEGSIZE=0x00000b80

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 10
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 

############################################ GAUSSD
BINFILE=gauss.bin
SEGADDR=0x0003cffc
SEGSIZE=0x00001000

# blkwrite command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x0000000E
# space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# sent extended message command
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA2A2A2A2
# let src get ready for data
sleep 1
# transfer data
hwblkio -W -b 3 -B 4 -s 32 -x -@0x0010023c -f $BINFILE
sleep 1
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
sleep 1
# MONCMD_PROGSYS command
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x001E0001
# ram space 1 = x
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00000001
# ram address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V 0x00008000
# rom address
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGADDR
# number of words
hwblkio -W -b 3 -B 4 -x -@0x0010023c -V $SEGSIZE
# sent HOSTCMD_BF F__monflashprog flash prog commands
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA6A6A6A6
sleep 10
# End with the host port in cmd buffer mode, srccmd
hwblkio -W -b 1 -B 1 -x -@0x00100224 -V 0xA3A3A3A3 
